package com.lekang.system.controller;

import com.lekang.common.core.domain.AjaxResult;
import com.lekang.system.domain.NursingPlanLevelBinding;
import com.lekang.system.service.INursingPlanLevelBindingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 护理计划与护理等级中间表Controller
 *
 *
 * @date 2025-10-15
 */
@RestController
@RequestMapping("/system/binding/plan-level")
public class NursingPlanLevelBindingController {

    @Autowired
    private INursingPlanLevelBindingService bindingService;

    /**
     * 查询中间表列表
     */
    @GetMapping("/list")
    public AjaxResult list(NursingPlanLevelBinding binding) {
        List<NursingPlanLevelBinding> list = bindingService.selectBindingList(binding);
        return AjaxResult.success(list);
    }

    /**
     * 新增中间表记录
     */
    @PostMapping
    public AjaxResult add(@RequestBody NursingPlanLevelBinding binding) {
        return AjaxResult.success(bindingService.insertBinding(binding));
    }

    /**
     * 批量新增中间表记录
     */
    @PostMapping("/batch")
    public AjaxResult batchAdd(@RequestBody List<NursingPlanLevelBinding> bindings) {
        return AjaxResult.success(bindingService.batchInsertBinding(bindings));
    }

    /**
     * 删除中间表记录（按护理计划ID）
     */
    @DeleteMapping("/plan/{planId}")
    public AjaxResult deleteByPlanId(@PathVariable Long planId) {
        return AjaxResult.success(bindingService.deleteBindingByPlanId(planId));
    }
}